package cn.lsc.controller;

import cn.lsc.domain.Person;
import cn.lsc.domain.User;
import cn.lsc.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IPersonService iPersonService;

    @Value("${server.port}")
    private String port;
//    @GetMapping("/findById/{id}")
//    public User findById(@PathVariable("id")Long id){
//        return new User(11L,"zs","我在源码当研究生"+port);
//    }

    @GetMapping("findAll")
    public List<Person> findAll(){
        return iPersonService.loadAll();
    }
    @GetMapping("/findById/{id}")
    public Person findById(@PathVariable("id") Long id){
       return  iPersonService.loadById(id);
    }

}
